SELECT T.*,
(
CASE
WHEN (SYSDATE BETWEEN NVL(T.BEGIN_DATE, SYSDATE) AND NVL(T.END_DATE, SYSDATE))
THEN '1'
ELSE '2'
END) AS valid_code
FROM c1_user t
WHERE (EXISTS
(SELECT 1
FROM eh_mobile_phone_bind e
WHERE (SYSDATE BETWEEN NVL(e.BEGIN_DATE, SYSDATE) AND NVL(e.END_DATE, SYSDATE))
AND t.MOBILE_PHONE = :code
AND e.user_id      = t.id
)
OR t.code = :code)
AND T.PASSWORD in (:password, :newPassword)